/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Chien
 */
@Entity
@Table(name = "TBL_EVENT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Event.findAll", query = "SELECT e FROM Event e"),
    @NamedQuery(name = "Event.findByEventId", query = "SELECT e FROM Event e WHERE e.eventId = :eventId"),
    @NamedQuery(name = "Event.findByTitle", query = "SELECT e FROM Event e WHERE e.title = :title"),
    @NamedQuery(name = "Event.findByPhoto", query = "SELECT e FROM Event e WHERE e.photo = :photo"),
    @NamedQuery(name = "Event.findByDescription", query = "SELECT e FROM Event e WHERE e.description = :description"),
    @NamedQuery(name = "Event.findByStartRegDate", query = "SELECT e FROM Event e WHERE e.startRegDate = :startRegDate"),
    @NamedQuery(name = "Event.findByEndRegDate", query = "SELECT e FROM Event e WHERE e.endRegDate = :endRegDate"),
    @NamedQuery(name = "Event.findByStartDate", query = "SELECT e FROM Event e WHERE e.startDate = :startDate"),
    @NamedQuery(name = "Event.findByEndDate", query = "SELECT e FROM Event e WHERE e.endDate = :endDate"),
    @NamedQuery(name = "Event.findByIsActive", query = "SELECT e FROM Event e WHERE e.isActive = :isActive"),
    @NamedQuery(name = "Event.findByMinPlayer", query = "SELECT e FROM Event e WHERE e.minPlayer = :minPlayer"),
    @NamedQuery(name = "Event.findByMaxPlayer", query = "SELECT e FROM Event e WHERE e.maxPlayer = :maxPlayer")})
public class Event implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "EventId")
    private String eventId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "Title")
    private String title;
    @Size(max = 100)
    @Column(name = "Photo")
    private String photo;
    @Size(max = 1000)
    @Column(name = "Description")    
    private String description;
    @Column(name = "StartRegDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startRegDate;
    @Column(name = "EndRegDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endRegDate;
    @Column(name = "StartDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startDate;
    @Column(name = "EndDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endDate;
    @Column(name = "isActive")
    private Boolean isActive;
    @Column(name = "MinPlayer")
    private Integer minPlayer;
    @Column(name = "MaxPlayer")
    private Integer maxPlayer;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventId")
    private List<Registration> registrationList;
    @OneToMany(mappedBy = "eventId")
    private List<Prize> prizeList;

    public Event() {
    }

    public Event(String eventId) {
        this.eventId = eventId;
    }

    public Event(String eventId, String title) {
        this.eventId = eventId;
        this.title = title;
    }

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getPhoto() {
        return photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getStartRegDate() {
        return startRegDate;
    }

    public void setStartRegDate(Date startRegDate) {
        this.startRegDate = startRegDate;
    }

    public Date getEndRegDate() {
        return endRegDate;
    }

    public void setEndRegDate(Date endRegDate) {
        this.endRegDate = endRegDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }

    public Integer getMinPlayer() {
        return minPlayer;
    }

    public void setMinPlayer(Integer minPlayer) {
        this.minPlayer = minPlayer;
    }

    public Integer getMaxPlayer() {
        return maxPlayer;
    }

    public void setMaxPlayer(Integer maxPlayer) {
        this.maxPlayer = maxPlayer;
    }

    @XmlTransient
    public List<Registration> getRegistrationList() {
        return registrationList;
    }

    public void setRegistrationList(List<Registration> registrationList) {
        this.registrationList = registrationList;
    }

    @XmlTransient
    public List<Prize> getPrizeList() {
        return prizeList;
    }

    public void setPrizeList(List<Prize> prizeList) {
        this.prizeList = prizeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (eventId != null ? eventId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Event)) {
            return false;
        }
        Event other = (Event) object;
        if ((this.eventId == null && other.eventId != null) || (this.eventId != null && !this.eventId.equals(other.eventId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return title;
    }
    
}
